package j2025.j03;

/**
 * @Author 猫大仙
 */
public class j0314 {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode ret = new ListNode(0);
        ListNode cur = ret;
        int tmp = 0;
        while(l1!=null || l2!=null || tmp!=0){
            if(l1!=null){
                tmp+=l1.val;
                l1 = l1.next;
            }
            if(l2!=null){
                tmp += l2.val;
                l2 = l2.next;
            }
            cur.next = new ListNode(tmp%10);
            cur = cur.next;
            tmp/=10;
        }
        return ret.next;
    }
}
